<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var str="";
    var level=prompt("请输入三角形的行数");
    for(i=1;i<=level;i++){
var star=i*2-1;
    
    for(var j=0;j<star;++j){
        str+="*";
    }
    str+="\n";
    }
alert(str);
</script>
</body>
</html>